package com.wu01.demo.mapper;

import com.wu01.demo.Entity.OrderInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderInfoMapper {
    @Select("select * from OrderInfo where id = #{id}")
    int selectById(Long id);

    @Delete("delete from OrderInfo where id = #{id}")
    int deleteById(Long id);

    @Insert("insert into OrderInfo(id,name,createDate,phone) values(#{id},#{name},#{createDate},#{phone})")
    int insert(OrderInfo record);

//    int insertSelective(OrderInfo record);

    @Select("select * from OrderInfo where name = #{name}")
    List<OrderInfo> selectByName(String name);

//    int updateByIdSelective(@Param("record") OrderInfo record, @Param("example") OrderInfo example);

    @Update("update OrderInfo set name = #{record.name},createDate = #{record.createDate}," +
            "phone = #{record.phone} where id = #{record.id} ")
    int updateById(OrderInfo record);

    /**
     * 查询全部订单
     * @return
     */
    @Select("select * from OrderInfo")
    List<OrderInfo> selectAll();

    /**
     * 分页查询订单
     * @return
     */
    @Select("select * from OrderInfo ")
    List<OrderInfo> selectPage();

    @Insert("insert into OrderInfo(id,name) values(#{id},#{name})")
    int addPage(OrderInfo orderInfo);
}